package edu.zhuoxun.blogserver.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import edu.zhuoxun.blogserver.entity.Category;
import edu.zhuoxun.blogserver.entity.Result;
import edu.zhuoxun.blogserver.map.CategoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class CategoryController {
    @Resource
    public CategoryMapper categoryMapper;


    @GetMapping("/api/category/list")
    @ResponseBody
    public Result<List<Category>> getList() {
        Result<List<Category>> result = new Result<>();
        List<Category> categories = categoryMapper.selectList(new QueryWrapper<>());
        result.setCode(200);
        result.setMessage("OK");
        result.setData(categories);
        return result;
    }
}
